﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Mail;

namespace IEWebSite.Pages.Intranet
{
    public partial class CerereSoftware : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (rcbSw.SelectedIndex == -1)
            {
                txtSoftware.ReadOnly = false;
            }
            lblError.Visible = false;
        }

        protected void btnTrimitere_Click(object sender, EventArgs e)
        {
            MailMessage msg = new MailMessage();

            msg.To = "andreea.diosteanu@ie.ase.ro";
            //aici trebuie luata acumva adresa de email a profesorului cu care este logat in sistem
            msg.From = "";
            msg.Subject ="Cerere software "+rcbLab.SelectedValue;
            string val="";
            if (rcbSw.SelectedIndex == -1)
            {
                val = txtSoftware.Text;
            }
            else 
            {
                val = rcbSw.SelectedValue;
            }
            msg.Body = "Buna ziua,"+"\n "+"Solicit in laboratorul "+rcbLab.SelectedValue+" software-ul"+val+" pentru disciplina "+rcbDisciplina.SelectedValue + ".\n"+"Va multumesc." ;
            try
            {
                SmtpMail.Send(msg);
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text = "ERROR: " + ex.Message;
            }
            lblError.Text = "Message successfully sent!";
           
        }
    }
}
